package thread;

public class ThreadDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        //守护线程设置
        Thread thread = new Thread(god);
        thread.setDaemon(true);
        //守护线程启动
        thread.start();

        //用户线程结束
        new Thread(you).start();
    }
}

class God implements Runnable {
    @Override
    public void run() {
        while (true) {
            System.out.println("上帝保佑你！");
        }
    }
}

class You implements Runnable {
    @Override
    public void run() {
        System.out.println("Hello world!");
        for (int i = 0; i < 36500; i++) {
            System.out.println("Happy every day");
        }
        System.out.println("Goodbye world!");
    }
}